package com.zhoug.map3.dianditu;

import com.zhoug.common3.Logger;

import org.osmdroid.tileprovider.tilesource.XYTileSource;
import org.osmdroid.util.MapTileIndex;

/**
 * 天地图瓦片资源
 *
 * @Author: zhoug
 * @Date: 2025-01-02
 * @Description:
 */
public class TianDiTuTileSource extends XYTileSource {
    private static final boolean DEBUG = false;
    private static final String TAG = ">>>TianDiTuTileSource";

    public TianDiTuTileSource(String aName, int aZoomMinLevel, int aZoomMaxLevel, int aTileSizePixels, String aImageFilenameEnding, String[] aBaseUrl) {
        super(aName, aZoomMinLevel, aZoomMaxLevel, aTileSizePixels, aImageFilenameEnding, aBaseUrl);
    }

    @Override
    public String getTileURLString(long pMapTileIndex) {
        if (DEBUG) {
            String tileURLString = TianDiTuTileSourceFactory.getTileURLString(getBaseUrl(), MapTileIndex.getZoom(pMapTileIndex), MapTileIndex.getY(pMapTileIndex), MapTileIndex.getX(pMapTileIndex));
            Logger.d(TAG, tileURLString);
            return tileURLString;
        }
        return TianDiTuTileSourceFactory.getTileURLString(getBaseUrl(), MapTileIndex.getZoom(pMapTileIndex), MapTileIndex.getY(pMapTileIndex), MapTileIndex.getX(pMapTileIndex));
    }

}
